package com.jinduplan.planmanager.mvp.model

import com.cxz.kotlin.baselibs.mvp.BaseModel
import com.cxz.kotlin.baselibs.utils.GsonHelper
import com.jinduplan.planmanager.bean.*
import com.jinduplan.planmanager.http.MainRetrofit
import com.jinduplan.planmanager.mvp.contract.MessageContract
import com.jinduplan.planmanager.mvp.contract.ProjectContract
import io.reactivex.rxjava3.core.Observable

/**
 * @author admin
 * @date 2018/11/20
 * @desc
 */
class MessageModel : BaseModel(), MessageContract.Model {

    override fun getMsgList(page: Int, limit: Int): Observable<HttpResult<MessageBean>> {
        val map = HashMap<String,Int>()
        map["page"] = page
        map["limit"] = limit

        return MainRetrofit.service.getMsgList(GsonHelper.getRequestIntBoby(map))
    }

    override fun readMessage(id: Int, is_read: Int): Observable<HttpResult<MessageBean>> {
        val map = HashMap<String,Int>()
        map["id"] = id
        map["is_read"] = is_read

        return MainRetrofit.service.readMsg(GsonHelper.getRequestIntBoby(map))
    }

    override fun getProjectList(
        page: Int,
        limit: Int,
        project_id:Int,
        audit_id:Int
    ): Observable<HttpResult<DataProjectBean>> {
        val map = HashMap<String,Int>()
        map["page"] = page
        map["limit"] = limit
        if(project_id!=0){
            map["project_id"]=project_id
        }
        if(audit_id!=0){
            map["audit_id"]=audit_id
        }
        return MainRetrofit.service.getProjectList(GsonHelper.getRequestIntBoby(map))
    }

}